home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH08 / EX8_5B.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-02-07  |  1.6 KB  |  80 lines

  1. ; Ex8_5b.asm
  2. ;
  3. ; PrintVowels Module
  4.  
  5.         .xlist
  6.         include     stdlib.a
  7.         includelib    stdlib.lib
  8.         .list
  9.  
  10. ; The following include directive brings in the
  11. ; EXTERNDEF directive for the PrintVowels routine
  12. ; so that this name will be global:
  13.  
  14.         include        Ex8_5.a
  15.  
  16.  
  17. cseg        segment    para public 'code'
  18.  
  19.  
  20.  
  21. ; PrintVowels-    On entry ES:DI points at a string
  22. ;        of characters.  This routine steps
  23. ;        through the string and prints each
  24. ;        character which is a vowel.
  25. ;
  26. ;        Note that the type of this procedure
  27. ;        (near or far) must exactly match
  28. ;        the type given in the EXTERNDEF
  29. ;        directive in the Lab8_10.a include
  30. ;        file.
  31.  
  32. PrintVowels    proc    near
  33.         push    es    ;Must preserve these
  34.         push    di    ; registers!
  35.         push    ax
  36.  
  37. PVLoop:        mov    al, es:[di]    ;Get next char
  38.         cmp    al, 0        ;End of str?
  39.         jne    ProcessChar
  40.         pop    ax
  41.         pop    di
  42.         pop    es
  43.         ret
  44.  
  45.  
  46. ; The following four statements demonstrate how to use
  47. ; the FORC macro to generate a sequence of CMP instrs
  48. ; which varies depending on the number of characters
  49. ; in the second parameter.
  50.  
  51. ProcessChar:
  52.         forc    char, <AaEeIiOoUuWwYy>
  53.         cmp    al, '&char'
  54.         je    IsAVowel
  55.         endm
  56.  
  57. ; If we get down here, the current character in AL is
  58. ; *not* a vowel
  59.  
  60.         inc    di    ;Move on to next char
  61.         jmp    PVLoop
  62.  
  63. ; If we get down here, the character in AL is a
  64. ; vowel so print it to the display.
  65.  
  66.         .nolistmacro
  67. IsAVowel:    putc
  68.         inc    di    ;Move on to next char
  69.         jmp    PVLoop
  70. PrintVowels    endp
  71. cseg        ends
  72.  
  73.  
  74. ; Note that there is generally only one set of SSEG and
  75. ; ZZZZZZSEG segments in an entire project.  They should
  76. ; not appear in modules which do not contain your main
  77. ; program.
  78.  
  79.         end
  80.